package 二叉树相关问题;

public class 对称的二叉树 {

    public boolean isSymmetric(TreeNode root) {
         if (root==null)
             return true;
         return connectTwoNode(root.left,root.right);
    }

    private boolean connectTwoNode(TreeNode left, TreeNode right) {
        if (left==null && right==null)
            return true;
        if (left!=null && right!=null && left.val==right.val)
            return connectTwoNode(left.left,right.right)&&connectTwoNode(left.right,right.left);
        return false;
    }
}
